package menus;
import javax.swing.JMenu;

import actions.AddSyntaxColorMenuAction;
import actions.AutoIncrementorAction;
import actions.ColumnModeMenuAction;
import actions.CreateDocumentTypeAction;
import actions.FindReplaceAction;
import actions.FoldingBorderAction;
import actions.NewFileAction;
import actions.OpenFileAction;
import actions.SaveFileAction;
import actions.SaveFileAsAction;

import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

import actions.ExampleMenuAction;

import misc.Vals;

/**
 * The AwesomeMenuBar has the following menus by default:
 * File
 * Edit
 */
public class AwesomeMenuBar extends JMenuBar {
	
	JMenu fileMenu;
	JMenu editMenu;
	
	public AwesomeMenuBar() {
		super();
		this.initComponents();
	}

	private void initComponents() {
		this.initFileMenu();
		this.initEditMenu();
	}

	/**
	 * Initialized the Edit menu.
	 */
	private void initEditMenu() {
		this.editMenu = new JMenu(Vals.editMenuText);
		this.add(editMenu);
		
		// Add Menu Items
		editMenu.add(new JMenuItem(new FindReplaceAction("FindAndReplace","Show Find and Replace Dialog")));
		editMenu.add(new JMenuItem(new AutoIncrementorAction("Auto Incrementor","Show AutoIncrementor Dialog")));
		editMenu.add(new JMenuItem(new FoldingBorderAction("Fold Code", "Fold Selected Text")));
		editMenu.add(new JCheckBoxMenuItem(new ColumnModeMenuAction("Column Mode", "Enable or Disable Column Mode Editing")));
		editMenu.addSeparator();
		editMenu.add(new JMenuItem(new CreateDocumentTypeAction("New Document Type", "Create new document type")));
		editMenu.add(new JMenuItem(new AddSyntaxColorMenuAction("Add Syntax", "Create new syntax")));
	}

	/**
	 * Initialized the File menu.
	 */
	private void initFileMenu() {
		this.fileMenu = new JMenu(Vals.fileMenuText);
		this.add(fileMenu);
		
		// Add Menu Items
		fileMenu.add(new JMenuItem(new NewFileAction("New", "Open new file.")));
		fileMenu.add(new JMenuItem(new OpenFileAction("Open", "Open a file.")));
		fileMenu.addSeparator();
		fileMenu.add(new JMenuItem(new SaveFileAction("Save", "Save the file.")));
		fileMenu.add(new JMenuItem(new SaveFileAsAction("Save As", "Save the file.")));
	}
	
	/**
	 * Adds item to the Edit Menu.
	 * @param item JMenuItem to be added.
	 */
	public void addEditMenuItem(JMenuItem item) {
		this.editMenu.add(item);
	}
	
	/**
	 * Adds item to the File Menu.
	 * @param item JMenuItem to be added.
	 */
	public void addFileMenuItem(JMenuItem item) {
		this.fileMenu.add(item);
	}
}
